package com.bawei.day0129.viewmodel;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;

import com.bawei.day0129.Bean.LogBean;
import com.bawei.day0129.base.BaseViewModel;
import com.bawei.day0129.utils.HttpUtils;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;

public class LoginViewModel extends BaseViewModel {
    public LoginViewModel(@NonNull Application application) {
        super(application);
    }
    private MutableLiveData<LogBean> getLogin=new MutableLiveData<>();

    public MutableLiveData<LogBean> getGetLogin(String a, String b) {
        HttpUtils
                .getHttpUtils()
                .getApisices().getLogin(a, b)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<LogBean>() {
                    @Override
                    public void accept(LogBean logBean) throws Exception {
                        getLogin.postValue(logBean);
                    }
                });
        return getLogin;
    }
}
